package com.eagle.roomcrawler;

import com.eagle.roomcrawler.util.HttpFilter;
import com.eagle.roomcrawler.util.HttpInterceptor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author llx
 * @Decription:加了过滤器和拦截器 为了以后权限做准备
 * @date:created in 11:42 2018/4/2
 * @modify by
 */
@SpringBootApplication
public class RoomCrawlerApplication extends WebMvcConfigurerAdapter {

	public static void main(String[] args) {
		SpringApplication.run(RoomCrawlerApplication.class, args);
	}


	//配置过滤器
	@Bean
	public FilterRegistrationBean httpFilter() {
		FilterRegistrationBean registrationBean = new FilterRegistrationBean();
		registrationBean.setFilter(new HttpFilter());
		registrationBean.addUrlPatterns("/threadLocal/*");
		return registrationBean;
	}

	//配置拦截器 extends WebMvcConfigurerAdapter 重写 addInterceptors
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(new HttpInterceptor()).addPathPatterns("/**");
	}
}
